import { http } from "@/utils/index";

export interface channel {
  id: number;
  name: string;
}
export interface channelsData {
  channels: channel[];
}
export function getHomeData() {
  return http<channelsData>({
    url: "/channels",
    method: "GET",
  });
}
// 请求params类型
export interface acticleReqParamsInt {
  channel_id: number;
  timestamp: string;
}
// 响应data类型
export interface articleResDataInt {
  pre_timestamp: string;
  results: article[];
}
export interface article {
  art_id: string,
	aut_id: string;
	aut_name: string;
	comm_count: number;
	cover: Cover;
	is_top: number;
	pubdate: string;
	title: string;
}
export interface Cover {
	type: number;
	images: string[];
}

export function getArticlesData(params: acticleReqParamsInt) {
  return http<articleResDataInt>({
    url: "/articles",
    method: "GET",
    params,
  });
}
// 详情
export interface IDetailData {
  art_id: string;
  title: string;
  pubdate: string;
  aut_id: string;
  content: string;
  aut_name: string;
  aut_photo: string;
  is_followed: boolean;
  is_collected: boolean;
  attitude: unknown;
  comm_count: number;
  read_count: number;
  like_count: number;
}
export function getArticlesDetailApi(art_id: string) {
  return http<IDetailData>({
    url: `/articles/${art_id}`,
    method: "GET"
  });
}
